<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/11
 * Time: 14:17
 */
namespace app\admin\controller;

use app\admin\controller\Base;
use app\admin\model\MemberAttrModel;
use app\admin\model\DepartmentModel;
use think\Db;

class Memberattr extends Base{
    /**
     * 客户属性
     * grade (等级) status(客户状态)
     * 确定 值 status 1.释放 2.成交 (不可更改)
     */
    public function index(){
        if(request()->isAjax()){
            $memAttr = new MemberAttrModel();
            $memAttrs = $memAttr->getAttrList();
            $memAttrArr = getTree(objToArray($memAttrs), false);
            return json(msg(1, $memAttrArr, 'ok'));
        }
        return $this->fetch();
    }
    /**
     * 添加客户属性(增)
     * (id)attrAdd
     */
    public function attrAdd(){
        $where['pid']= (int)input('pid');
        $where['name'] =  input('attr_value');
        $memAttr = new MemberAttrModel();
        return $memAttr->addAttr($where);
        
    }
    /**
     * 编辑客户属性(改)
     * (id)editAtte
     */
    public function editAttr(){
        $where['id']= (int)input('attr_id');
        $where['name'] =  input('e_attr_value');
        $memAttr = new MemberAttrModel();
        return $memAttr->editAttr($where);
    }
    /**
     * 删除客户属性(删)
     * (id)delAtte
     */
    public function delAttr(){
        $param = input('get.id');
        $memAttr = new MemberAttrModel();
        return $memAttr->delAttr($param);
    }
}